//
//  ReleaseSubTagCell.m
//  ShowYork
//
//  Created by hxh on 2020/12/21.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "DynamicSubTopicCell.h"

@interface DynamicSubTopicCell ()
@property (nonatomic,strong)UIImageView *tagImgView;
@property (nonatomic,strong)UILabel *nameLb;
@property (nonatomic,strong)UIButton *coverBtn;
@end

@implementation DynamicSubTopicCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{

    self.tagImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"social_#_add_black_tag"]];
    [self.contentView addSubview:self.tagImgView];
    [self.tagImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(18);
        make.centerY.equalTo(self.contentView);
    }];
    
    self.nameLb = [[UILabel alloc]init];
    self.nameLb.text = @"提分秘籍";
    self.nameLb.textColor = C51;
    self.nameLb.font =font(14);
    [self.contentView addSubview:self.nameLb];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.tagImgView.mas_right).offset(10);
    }];
    
    self.coverBtn = [[UIButton alloc]init];
    [self.coverBtn addTarget:self action:@selector(coverMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.coverBtn];
    [self.coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
        make.height.mas_equalTo(40.0f).priorityHigh();
    }];
    
}
- (void)coverMethod{
    if (self.deletate && [self.deletate respondsToSelector:@selector(selectedSubTopicItemModel:)]) {
        [self.deletate selectedSubTopicItemModel:self.model];
    }
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"DynamicSubTopicCell";
    DynamicSubTopicCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[DynamicSubTopicCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (void)setModel:(SocialSubTopicModel *)model{
    _model = model;
    self.nameLb.text = model.topicName;
}

@end
